<template>
  <div class="images-wrapper normalColor" if="kcalType === 2">
    <img src="../../assets/img/evaluation_normal_bg.png" alt="" style="width: 100%;height: 100%;float: left;">
    <div class="images-content">
      所在班级能量含量如下
    </div>
    <div class="images-lab">
      {{  letEnergy.start }}～{{ letEnergy.end }} <span>kcal</span>
    </div>
  </div>

  <div id="enerty">
    <div id="params">
      <div class="shu"></div>
      营养方案标准 <span>具体如下：</span></div>
    <ul>
      <li class="bt"><span>元素</span><span>参考范围</span></li>
      <li class="bt"><span>元素</span><span>参考范围</span></li>
      <li class="element" :class="[letEnergy.color]"><span>能量</span><span>{{ letEnergy.keyword }}</span><span>{{  letEnergy.start }}～{{ letEnergy.end }}</span></li>
      <li class="element" :class="[protein.color]"><span>蛋白质</span><span>{{ protein.keyword }}</span><span>{{ protein.start }}～{{ protein.end }}</span></li>
      <li class="element" :class="[fat.color]"><span>脂肪</span><span>{{ fat.keyword }}</span><span>{{ fat.start }}～{{ fat.end }}</span></li>
      <li class="element" :class="[carbohydrate.color]"><span>碳水化合物</span><span>{{ carbohydrate.start }}～{{ carbohydrate.end }}</span></li>
      <li class="element" :class="[calcium.color]"><span>钙</span><span>{{ calcium.start }}～{{ calcium.end }}</span></li>
      <li class="element" :class="[sodium.color]"><span>钠</span><span>{{ sodium.start }}～{{ sodium.end }}</span></li>
      <li class="element" :class="[magnesium.color]"><span>镁</span><span>{{ magnesium.start }}～{{ magnesium.end }}</span></li>
      <li class="element" :class="[iron.color]"><span>铁</span><span>{{ iron.start }}～{{ iron.end }}</span></li>
      <li class="element" :class="[zinc.color]"><span>锌</span><span>{{ zinc.start }}～{{ zinc.end }}</span></li>
      <li class="element" :class="[selenium.color]"><span>硒</span><span>{{ selenium.start }}～{{ selenium.end }}</span></li>
      <li class="element" :class="[vitamin_a.color]"><span>维生素A</span><span>{{ vitamin_a.start }}～{{ vitamin_a.end }}</span></li>
      <li class="element" :class="[vitamin_e.color]"><span>维生素E</span><span>{{ vitamin_e.start }}～{{ vitamin_e.end }}</span></li>
      <li class="element" :class="[vitamin_b1.color]"><span>维生素B1</span><span>{{ vitamin_b1.start }}～{{ vitamin_b1.end }}</span></li>
      <li class="element" :class="[vitamin_b2.color]"><span>维生素B2</span><span>{{ vitamin_b2.start }}～{{ vitamin_b2.end }}</span></li>
      <li class="element" :class="[vitamin_c.color]"><span>维生素C</span><span>{{ vitamin_c.start }}～{{ vitamin_c.end }}</span></li>
    </ul>
    <div id="params">
      <div class="shu"></div>
      生长发育标准 <span>具体如下：</span></div>
    <ul>
      <li class="element" :class="[vitamin_c.color]"><span>男孩身高</span><span>{{ man.height }}CM</span></li>
      <li class="element" :class="[vitamin_c.color]"><span>男孩体重</span><span>{{ man.weight }}KG</span></li>
      <li class="element" :class="[vitamin_c.color]"><span>女孩身高</span><span>{{ woman.height }}CM</span></li>
      <li class="element" :class="[vitamin_c.color]"><span>女孩体重</span><span>{{ woman.weight }}KG</span></li>
    </ul>
  </div>

</template>

<script setup>
import {defineComponent, onMounted, ref, watch} from 'vue';
import {ElMessage} from "element-plus";
import * as api from "../../api/loginHttp";
import http, {baseUrl} from "../../utils/http";
import {useRoute, useRouter} from "vue-router"


const router = useRouter()
const route = useRoute()
const labName = ref()
const groupId = ref()
const reportId = ref()
const id = ref()
const imgUrl = ref()

const letEnergy = ref({'energy': 0, 'start':0, 'end':0})
const protein = ref({'energy': 0, 'start':0, 'end':0})
const fat = ref({'energy': 0, 'start':0, 'end':0})
const carbohydrate= ref({'energy': 0, 'start':0, 'end':0})
const calcium = ref({'energy': 0, 'start':0, 'end':0})
const sodium = ref({'energy': 0, 'start':0, 'end':0})
const magnesium = ref({'energy': 0, 'start':0, 'end':0})
const iron = ref({'energy': 0, 'start':0, 'end':0})
const zinc = ref({'energy': 0, 'start':0, 'end':0})
const selenium = ref({'energy': 0, 'start':0, 'end':0})
const vitamin_a =ref({'energy': 0, 'start':0, 'end':0})
const vitamin_e = ref({'energy': 0, 'start':0, 'end':0})
const vitamin_b1 = ref({'energy': 0, 'start':0, 'end':0})
const vitamin_b2 = ref({'energy': 0, 'start':0, 'end':0})
const vitamin_c =ref({'energy': 0, 'start':0, 'end':0})
const man =ref({'height': 0, 'weight':0})
const woman =ref({'height': 0, 'weight':0})
const diet_analysis = ref({})

const onHome = async () => {
  await router.push({'path': '/Home'})
}
const kcalType = ref(2)

const fetchData = async () => {
  if (route.params.groupId) {
    groupId.value = route.params.groupId
    id.value = route.params.id
    reportId.value = route.params.reportId
    if (groupId.value === 3) {
      labName.value = '婴幼儿营养测评'
    } else if (groupId.value === 5) {
      labName.value = '孕产妇营养测评'
    } else if (groupId.value === 6) {
      labName.value = '成年人营养测评'
    } else if (groupId.value === 7) {
      labName.value = '慢性病营养测评'
    } else {
      labName.value = '婴幼儿营养测评'
    }

    imgUrl.value = "http://"+baseUrl+'/';

    let params = {
      'groupId': groupId.value,
      'id': id.value,
      'reportId': reportId.value,
    }
    const data = await api.getFoodPackage(params);

    if(data.data.code == 0) {
      ElMessage.error(data.data.msg)
      await router.push({'path':'/Evaluation/' + groupId.value +'/'+ id})
    }
    letEnergy._value.start = data.data.data[0].start_package;
    letEnergy._value.end = data.data.data[0].end_package;

    protein._value.start = data.data.data[1].start_package;
    protein._value.end = data.data.data[1].end_package;

    fat._value.start = data.data.data[2].start_package;
    fat._value.end = data.data.data[2].end_package;

    carbohydrate._value.start = data.data.data[3].start_package;
    carbohydrate._value.end = data.data.data[3].end_package;

    calcium._value.start = data.data.data[4].start_package;
    calcium._value.end = data.data.data[4].end_package;

    sodium._value.start = data.data.data[5].start_package;
    sodium._value.end = data.data.data[5].end_package;

    magnesium._value.start = data.data.data[6].start_package;
    magnesium._value.end = data.data.data[6].end_package;

    iron._value.start = data.data.data[7].start_package;
    iron._value.end = data.data.data[7].end_package;

    zinc._value.start = data.data.data[8].start_package;
    zinc._value.end = data.data.data[8].end_package;

    selenium._value.start = data.data.data[9].start_package;
    selenium._value.end = data.data.data[9].end_package;

    vitamin_a._value.start = data.data.data[10].start_package;
    vitamin_a._value.end = data.data.data[10].end_package;

    vitamin_e._value.start = data.data.data[11].start_package;
    vitamin_e._value.end = data.data.data[11].end_package;

    vitamin_b1._value.start = data.data.data[12].start_package;
    vitamin_b1._value.end = data.data.data[12].end_package;

    vitamin_b2._value.start = data.data.data[13].start_package;
    vitamin_b2._value.end = data.data.data[13].end_package;

    vitamin_c._value.start = data.data.data[14].start_package;
    vitamin_c._value.end = data.data.data[14].end_package;

    man._value.height = data.data.data['man'].height;
    man._value.weight = data.data.data['man'].weight;
    woman._value.height = data.data.data['WomanAges'].height;
    woman._value.weight = data.data.data['WomanAges'].weight;
  } else {
    ElMessage.error('栏目编号不得为空')
    await router.push({'path': '/Home'})
  }
}
const pageList = async () => {
  await router.push({'path': '/pageList/' + groupId.value})
}
onMounted(() => {
  fetchData()
})
</script>

<style scoped>
.right-box-card {
  margin-left: 2%;
  margin-top: 1%;
  position: static;
  top: calc(260px);
  width: 60%;
  float: left;
  /*min-height: 650px;*/
}

.images-wrapper {
  width: 100%;
  position: relative;
  height: 173px;
  font-weight: bold;
}
.foodsNames {
  color:red;
}

.images-content {
  position: absolute;
  z-index: 1;
  line-height: 54px;
  top: calc(55% - 54px);
  overflow: hidden;
  margin-left: 55%;
  font-size: 18px;

}

.service_plate {
  background: url('../../assets/img/evaluaction_service_plate.png') center no-repeat;
}

.dietOn {
  height: 500px;
}

.everyRed {
  color:red;
}

.everyOrange {
  color:orange;
}

.everyBlack {
  color:#333333;
}

.time-botton {
  background-color: #2AB28B;
  width: 108px;
  height: 41px;
  color: #fff;
  font-size: 16px;
  border-radius: 100px;
  line-height: 41px;
  margin: 40px 0 0 40px;
  text-align: center;
}

.time-type {
  width: 58px;
  height: 58px;
  line-height: 58px;
  text-align: center;
  background: #85CE61;
  border-radius: 50%;
  opacity: 1;
  color: #fff;
  box-shadow: 5px 5px 2px #888888;
  margin: 20px 0 20px 40%;
}

.der{
  width: 354px;
  height: 241px;
  background: url("../../assets/img/evaluaction_service_plate.png") 100% 100%;
}

.platesFoods{
  margin-top: 5px;
  margin-left: 8px;

  color: #333333;
  font-size: 16px;
}
.platesFoods div {
  padding-bottom: 18px;

}
.platesFoods span{
  color: #666666;
}

.plates {
  width: 33%;
  float: left;
}

.plates .plates-top-img {
  float: left;
  margin-left: 1%;
}

.time-left-color {
  background: #85CE61;
}

.time-common-color {
  background: #E8B973;
}

.time-right-color {
  background: #6EA9E0;
}

.images-lab {
  position: absolute;
  z-index: 1;
  line-height: 54px;
  top: calc(85% - 54px);
  overflow: hidden;
  margin-left: 55%;
  font-size: 50px;
}

#params {
  margin-top: 3%;
  font-size: 22px;
  font-weight: bold;
}

.shu {
  width: 5px;
  height: 30px;
  background: #626aef;
  opacity: 1;
  border-radius: 100px;
  float: left;
  margin-right: 2%;
  margin-left: 3%;
}

#params span {
  font-size: 15px;
  color: #666;
  margin-left: 2%;
}

li {
  list-style-type: none;
}

#params ul {
  margin-left: 3%;
}

.topColor {
  color: #E8B973;
}

.topBgColor {
  border: 1px solid #E8B973;
  background-color: #E8B973;
}

.normalColor {
  color: #626aef;
}

.normalBgColor {
  border: 1px solid #2AB28B;
  background-color: #2AB28B;
}

.bottomColor {
  color: #6CA9E3;
}

.bottomBgColor {
  border: 1px solid #6CA9E3;
  background-color: #6CA9E3;
}

.images-lab span {
  font-size: 18px;
}

.images-right {
  position: absolute;
  z-index: 1;
  left: 0;
  bottom: 0;
  width: 15%;
  height: 20%;
  line-height: 34px;
  top: calc(95% - 54px);
  overflow: hidden;
  margin-left: 75%;
  font-size: 18px;
  border-radius: 30px;
  color: #fff;
  text-align: center;
}


#enerty .bt {
  background: #F7F7F7;
  color: #fff;
}

#enerty .bt span {
  width: 50%;
  float: left;
  text-align: center;
  color: #999999;
  line-height: 30px;
}

#enerty ul li {
  width: 48%;
  display: inline-block;
  margin: 0;
}

#enerty .element span {
  width: 50%;
  float: left;
  text-align: center;
  line-height: 50px;
}

</style>
